package top.rish.minfire.config;

import org.noear.solon.annotation.Bean;
import org.noear.solon.annotation.Configuration;
import org.noear.solon.annotation.Inject;
import org.noear.solon.view.freemarker.FreemarkerRender;

@Configuration
public class FreemarkerConfig {

    @Bean
    public void  freemarker_config_( @Inject FreemarkerRender render){

        freemarker.template.Configuration provider = render.getProvider();
        freemarker.template.Configuration providerOfDebug = render.getProviderOfDebug();

        setSyntax(provider);
        setSyntax(providerOfDebug);

    }

    private static void setSyntax(freemarker.template.Configuration configuration){
        if(configuration!=null){
            configuration.setTagSyntax(freemarker.template.Configuration.SQUARE_BRACKET_TAG_SYNTAX);
            configuration.setInterpolationSyntax(freemarker.template.Configuration.SQUARE_BRACKET_INTERPOLATION_SYNTAX);
            configuration.setTemplateExceptionHandler(new MyExceptionHandler());
        }
    }

}
